<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="struts"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>注册页面</title>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	<style type="text/css">
		<!--
		body {
			background-color: #aed4ff;
		}
		-->
	</style>

	<script>
	
		function isEmail(str) {
			var myReg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/;
			if (myReg.test(str))
				return true;
			return false;
		}

		function isNumberOr_Letter(s) {//判断是否是数字或字母 

			var regu = "^[0-9a-zA-Z\_]+$";
			var re = new RegExp(regu);
			if (re.test(s)) {
				return true;
			} else {
				return false;
			}
		}

		function isNull(str) {
			if (str == "")
				return true;
			var regu = "^[ ]+$";
			var re = new RegExp(regu);
			return re.test(str);
		}

		function verify() {
			if (isNull(document.getElementById("name_js").value)) {
				alert("名字不能为空");
				return false;
			} else if (!isNumberOr_Letter(document.getElementById("name_js").value)) {
				alert("名字只能为数字、字母、和下划线！");
				return false;
			} else if (document.getElementById("pwd_js").value != (document
					.getElementById("pwd_confirm_js").value)) {
				alert("两次输入的密码不相同！");
				return false;
			} else if (isNull(document.getElementById("pwd_js").value)) {
				alert("密码不能为空");
				return false;
			} else if (!isEmail(document.getElementById("email_js").value)) {
				alert("email格式不对");
				return false;
			} else
				return true;

		}
		
	</script>
	</head>
	<body>
	
		<img src="/bookshop-online/image/bupt_add.jpg" width="237" height="240" hspace="200" vspace="150">
		
		<div style="margin: -400px 0px 0px 500px;">
			<struts:form action="registerAction_cartRegister">
				<struts:label value="注册"></struts:label>
				<struts:textfield name="user.name" label="账号" id="name_js"/>
				<struts:password name="user.password" label="密码" id="pwd_js"/>
				<struts:password name="user.passwordConfirm" label="密码确认" id="pwd_confirm_js"/>
				<struts:textfield name="user.email" label="邮箱" id="email_js"/>
				<struts:textfield name="user.idcard" label="身份证号" id="idcard_js"/>
				<struts:textfield name="user.tel" label="电话" id="tel_js"/>
				<struts:textfield name="user.address" label="地址" id="address_js"/>
				<struts:textfield name="user.postcode" label="邮编" id="postcode_js"/>
				<struts:textfield name="user.truename" label="真实姓名" id="truename_js"/>
				<struts:submit value="注册" onclick="return verify();"></struts:submit>
			</struts:form>
		</div>
		
	</body>
</html>